From bbdb97d8c958a0cbc5f1111bda8a3a2e232d677b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Wed, 22 Jul 2026 18:27:37 +0000 Subject: [PATCH] Remove the ATTENDANCE table from the db --- db/schemas/lib/triggers/Makefile | 1 - db/schemas/lib/triggers/create/attendance.m4 | 93 ------------------- db/schemas/lib/triggers/drop/attendance.m4 | 23 ----- db/schemas/sokwedb/indexes/Makefile | 2 +- .../sokwedb/indexes/create/attendance.m4 | 33 ------- db/schemas/sokwedb/indexes/drop/attendance.m4 | 27 ------ db/schemas/sokwedb/tables/Makefile | 1 - .../sokwedb/tables/create/attendance.m4 | 34 ------- 8 files changed, 1 insertion(+), 213 deletions(-) delete mode 100644 db/schemas/lib/triggers/create/attendance.m4 delete mode 100644 db/schemas/lib/triggers/drop/attendance.m4 delete mode 100644 db/schemas/sokwedb/indexes/create/attendance.m4 delete mode 100644 db/schemas/sokwedb/indexes/drop/attendance.m4 delete mode 100644 db/schemas/sokwedb/tables/create/attendance.m4 diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 2ef5b2e..7202876 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -39,7 +39,6 @@ ORDER := comm_ids \ food_events \ groomings \ groom_scans_b \ - attendance \ arrivals_a \ swelling_sources \ humans \ diff --git a/db/schemas/lib/triggers/create/attendance.m4 b/db/schemas/lib/triggers/create/attendance.m4 deleted file mode 100644 index 9bb4aaf..0000000 --- a/db/schemas/lib/triggers/create/attendance.m4 +++ /dev/null @@ -1,93 +0,0 @@ -dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ -dnl -dnl This program is free software: you can redistribute it and/or modify it -dnl under the terms of the GNU Affero General Public License as published by -dnl the Free Software Foundation, either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU Affero General Public License for more details. -dnl -dnl You should have received a copy of the GNU Affero General Public License -dnl along with this program. If not, see . -dnl -dnl Triggers for the biography_data table -dnl -dnl Karl O. Pinc - -dnl m4 includes -include(`copyright.m4')dnl -include(`constants.m4')dnl -include(`macros.m4')dnl - - -RAISE INFO 'attendance_func'; -CREATE OR REPLACE FUNCTION attendance_func () - RETURNS trigger - LANGUAGE plpgsql - sdb_function_set_search_path - AS $$ - BEGIN - -- Function for attendance insert and update triggers - -- - -- AGPL_notice(` --', `2026', - `The Meme Factory, Inc., www.karlpinc.com') - - IF TG_OP = 'UPDATE' THEN - cannot_change(`ATTENDANCE', `AtID') - END IF; - - -- An individual censused at the feeding station must be under study. - -- (Maybe this should be 2 different tests and 2 error messages - -- to make it easy on the user's brain, like we do everywhere else? - -- But this is less code.) - IF TG_OP = 'INSERT' - OR NEW.date <> OLD.date THEN - DECLARE - a_entrydate biography_data.entrydate%TYPE; - a_departdate biography_data.departdate%TYPE; - - BEGIN - SELECT biography_data.entrydate, biography_data.departdate - INTO a_entrydate , a_departdate - FROM biography_data - WHERE biography_data.animid = NEW.animid - AND (NEW.date < biography_data.entrydate - OR NEW.date > biography_data.departdate); - IF FOUND THEN - RAISE EXCEPTION integrity_constraint_violation USING - MESSAGE = 'Error on ' || TG_OP || ' of ATTENDANCE' - , DETAIL = 'An individual must be under study to be censused' - || ' at the feeding station,' - || ' the ATTENDANCE.Date cannot be before' - || ' BIOGRAPHY_DATA.EntryDate or after' - || ' BIOGRAPHY_DATA.DepartDate' - || ': Key (AtID) = (' - || NEW.atid - || '), Value (AnimID) = (' - || NEW.animid - || '), Value (Date) = (' - || NEW.date - || '), Value (CommID) = (' - || NEW.commid - || '), Value (BIOGRAPHY_DATA.EntryDate) = (' - || a_entrydate - || '), Value (BIOGRAPHY_DATA.DepartDate) = (' - || a_departdate - || ')'; - END IF; - END; - END IF; - - RETURN NULL; - END; -$$; - - -RAISE INFO 'attendance_trigger'; -CREATE TRIGGER attendance_trigger - AFTER INSERT OR UPDATE - ON attendance FOR EACH ROW - EXECUTE PROCEDURE attendance_func(); diff --git a/db/schemas/lib/triggers/drop/attendance.m4 b/db/schemas/lib/triggers/drop/attendance.m4 deleted file mode 100644 index 543ab85..0000000 --- a/db/schemas/lib/triggers/drop/attendance.m4 +++ /dev/null @@ -1,23 +0,0 @@ -dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ -dnl -dnl This program is free software: you can redistribute it and/or modify -dnl it under the terms of the GNU Affero General Public License as published by -dnl the Free Software Foundation, either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU Affero General Public License for more details. -dnl -dnl You should have received a copy of the GNU Affero General Public License -dnl along with this program. If not, see . -dnl -dnl Drop triggers for attendance table -dnl -dnl Karl O. Pinc - -dnl m4 includes -include(`copyright.m4')dnl - -DROP FUNCTION IF EXISTS attendance_func() CASCADE; diff --git a/db/schemas/sokwedb/indexes/Makefile b/db/schemas/sokwedb/indexes/Makefile index 7e3e977..45acdec 100644 --- a/db/schemas/sokwedb/indexes/Makefile +++ b/db/schemas/sokwedb/indexes/Makefile @@ -22,7 +22,7 @@ ORDER := biography_data comm_membs comm_memb_log \ watches follow_observers follow_studies events roles arrivals \ swelling_sources swelling_states sightings \ - aggressions food_events groomings attendance \ + aggressions food_events groomings \ arrivals_a species_present repro_states locations_utm \ locations_paper colobus matings fertility elo_ranks_daily_kk_f \ elo_ranks_daily_kk_m elo_ranks_daily_mt_f elo_ranks_daily_mt_m diff --git a/db/schemas/sokwedb/indexes/create/attendance.m4 b/db/schemas/sokwedb/indexes/create/attendance.m4 deleted file mode 100644 index 118cf10..0000000 --- a/db/schemas/sokwedb/indexes/create/attendance.m4 +++ /dev/null @@ -1,33 +0,0 @@ -dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ -dnl -dnl This program is free software: you can redistribute it and/or modify -dnl it under the terms of the GNU Affero General Public License as published -dnl by the Free Software Foundation, either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU Affero General Public License for more details. -dnl -dnl You should have received a copy of the GNU Affero General Public License -dnl along with this program. If not, see . -dnl -dnl Karl O. Pinc -dnl -dnl -dnl m4 includes -include(`copyright.m4')dnl -include(`constants.m4')dnl -include(`indexmacros.m4')dnl - -CREATE UNIQUE INDEX IF NOT EXISTS - "On ATTENDANCE, AnimID + Date must be unique" - ON attendance - (date, animid); - -CREATE INDEX IF NOT EXISTS attendance_animid ON attendance - (animid); -CREATE INDEX IF NOT EXISTS attendance_commid ON attendance - (commid); - diff --git a/db/schemas/sokwedb/indexes/drop/attendance.m4 b/db/schemas/sokwedb/indexes/drop/attendance.m4 deleted file mode 100644 index 01e4190..0000000 --- a/db/schemas/sokwedb/indexes/drop/attendance.m4 +++ /dev/null @@ -1,27 +0,0 @@ -dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ -dnl -dnl This program is free software: you can redistribute it and/or modify -dnl it under the terms of the GNU Affero General Public License as published -dnl by the Free Software Foundation, either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU Affero General Public License for more details. -dnl -dnl You should have received a copy of the GNU Affero General Public License -dnl along with this program. If not, see . -dnl -dnl Karl O. Pinc -dnl -dnl -dnl m4 includes -include(`copyright.m4')dnl -include(`constants.m4')dnl -include(`indexmacros.m4')dnl - -DROP INDEX IF EXISTS "On ATTENDANCE, AnimID + Date must be unique"; - -DROP INDEX IF EXISTS attendance_animid; -DROP INDEX IF EXISTS attendance_commid; diff --git a/db/schemas/sokwedb/tables/Makefile b/db/schemas/sokwedb/tables/Makefile index c46cbd0..24e6714 100644 --- a/db/schemas/sokwedb/tables/Makefile +++ b/db/schemas/sokwedb/tables/Makefile @@ -29,7 +29,6 @@ ORDER := biography_data \ watches \ follow_observers \ follow_studies \ - attendance \ events \ roles \ humans \ diff --git a/db/schemas/sokwedb/tables/create/attendance.m4 b/db/schemas/sokwedb/tables/create/attendance.m4 deleted file mode 100644 index 64f6992..0000000 --- a/db/schemas/sokwedb/tables/create/attendance.m4 +++ /dev/null @@ -1,34 +0,0 @@ -dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ -dnl -dnl This program is free software: you can redistribute it and/or modify -dnl it under the terms of the GNU Affero General Public License as published -dnl by the Free Software Foundation, either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU Affero General Public License for more details. -dnl -dnl You should have received a copy of the GNU Affero General Public License -dnl along with this program. If not, see . -dnl -dnl Karl O. Pinc -dnl -dnl -dnl m4 includes -include(`copyright.m4')dnl -include(`constants.m4')dnl -include(`tablemacros.m4')dnl -include(`grants.m4')dnl -dnl - -CREATE TABLE attendance ( - key_column(`ATTENDANCE', `AtID', INTEGER) - ,animid_column() - ,date DATE NOT NULL - ,commid TEXT NOT NULL - REFERENCES comm_ids -); - -grant_priv(`ATTENDANCE') -- 2.34.1